package com.lemobar.pay.enums;

/**
 * 微信错误码枚举
 */
public enum WxErrorCodeEnum {
    SYSTEMERROR("SYSTEMERROR", "接口返回错误"),       //
    BANKERROR("BANKERROR", "银行系统异常"),
    USERPAYING("USERPAYING", "用户支付中，需要输入密码"),

    ;

    /**
     * 接口名称
     * method code
     */
    private final String code;

    /**
     * 描述
     */
    private final String desc;

    WxErrorCodeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static WxErrorCodeEnum findByName(String name) {
        for (WxErrorCodeEnum wxErrorCodeEnum : WxErrorCodeEnum.values()) {
            if (name.toLowerCase().equals(wxErrorCodeEnum.name().toLowerCase())) {
                return wxErrorCodeEnum;
            }
        }
        throw new RuntimeException("错误的微信错误码");
    }
    public static WxErrorCodeEnum findByCode(String code) {
        for (WxErrorCodeEnum wxErrorCodeEnum : WxErrorCodeEnum.values()) {
            if (code.toLowerCase().equals(wxErrorCodeEnum.code.toLowerCase())) {
                return wxErrorCodeEnum;
            }
        }
        throw new RuntimeException("错误的微信错误码");
    }
}
